﻿#region Copyright (c) 2000-2013 Developer Express Inc.
/*
{*******************************************************************}
{                                                                   }
{       Developer Express .NET Component Library                    }
{                                                                   }
{                                                                   }
{       Copyright (c) 2000-2013 Developer Express Inc.              }
{       ALL RIGHTS RESERVED                                         }
{                                                                   }
{   The entire contents of this file is protected by U.S. and       }
{   International Copyright Laws. Unauthorized reproduction,        }
{   reverse-engineering, and distribution of all or any portion of  }
{   the code contained in this file is strictly prohibited and may  }
{   result in severe civil and criminal penalties and will be       }
{   prosecuted to the maximum extent possible under the law.        }
{                                                                   }
{   RESTRICTIONS                                                    }
{                                                                   }
{   THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES           }
{   ARE CONFIDENTIAL AND PROPRIETARY TRADE                          }
{   SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS   }
{   LICENSED TO DISTRIBUTE THE PRODUCT AND ALL ACCOMPANYING .NET    }
{   CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY.                 }
{                                                                   }
{   THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED      }
{   FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE        }
{   COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE       }
{   AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT  }
{   AND PERMISSION FROM DEVELOPER EXPRESS INC.                      }
{                                                                   }
{   CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON       }
{   ADDITIONAL RESTRICTIONS.                                        }
{                                                                   }
{*******************************************************************}
*/
#endregion Copyright (c) 2000-2013 Developer Express Inc.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using UColor.Core.Helpers;
using DevExpress.Xpf.Core;
#if SL
using DevExpress.Xpf.Core.WPFCompatibility;
#endif
namespace UColor.WPF {
	public class BaseControlTileSelector : UniversalControl {
		#region Dependency Properties
		public static readonly DependencyProperty ItemTemplateSelectorProperty;
		public static readonly DependencyProperty ItemTemplateProperty;
		public static readonly DependencyProperty GroupHeaderTemplateProperty;
		public static readonly DependencyProperty ItemsSourceProperty;
		static BaseControlTileSelector() {
			Type ownerType = typeof(BaseControlTileSelector);
			ItemTemplateSelectorProperty = DependencyProperty.Register("ItemTemplateSelector", typeof(DataTemplateSelector), ownerType, new PropertyMetadata(null, RaiseItemTemplateSelectorChanged));
			ItemTemplateProperty = DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), ownerType, new PropertyMetadata(null, RaiseItemTemplateChanged));
			GroupHeaderTemplateProperty = DependencyProperty.Register("GroupHeaderTemplate", typeof(DataTemplate), ownerType, new PropertyMetadata(null, RaiseGroupHeaderChanged));
			ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(IEnumerable), ownerType, new PropertyMetadata(null, RaiseItemsSourceChanged));
		}
		DataTemplateSelector itemTemplateSelectorValue = null;
		DataTemplate itemTemplateValue = null;
		DataTemplate groupHeaderTemplateValue = null;
		IEnumerable itemsSourceValue = null;
		static void RaiseItemTemplateSelectorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
			((BaseControlTileSelector)d).itemTemplateSelectorValue = (DataTemplateSelector)e.NewValue;
		}
		static void RaiseItemTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
			((BaseControlTileSelector)d).itemTemplateValue = (DataTemplate)e.NewValue;
		}
		static void RaiseGroupHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
			((BaseControlTileSelector)d).groupHeaderTemplateValue = (DataTemplate)e.NewValue;
		}
		static void RaiseItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
			((BaseControlTileSelector)d).itemsSourceValue = (IEnumerable)e.NewValue;
		}
		#endregion
		public BaseControlTileSelector() {
			this.SetDefaultStyleKey(typeof(BaseControlTileSelector));
			FocusHelper2.SetFocusable(this, false);
		}
		public DataTemplateSelector ItemTemplateSelector { get { return itemTemplateSelectorValue; } set { SetValue(ItemTemplateSelectorProperty, value); } }
		public DataTemplate ItemTemplate { get { return itemTemplateValue; } set { SetValue(ItemTemplateProperty, value); } }
		public DataTemplate GroupHeaderTemplate { get { return groupHeaderTemplateValue; } set { SetValue(GroupHeaderTemplateProperty, value); } }
		public IEnumerable ItemsSource { get { return itemsSourceValue; } set { SetValue(ItemsSourceProperty, value); } }
	}
}
